# -*- coding: UTF-8 -*-
from elasticsearch import Elasticsearch
import asyncio

es_index = 'ipsearch_v2_20190902'
es_type = 'xsPatent'

es = Elasticsearch(hosts=[{'host': "192.168.1.167", 'port': "9200"}], timeout=30)


# 定义异步函数
async def bulk_delete():
    query = {
        'query': {
            "match_all": {}
        }
    }
    es.delete_by_query(index=es_index, body=query, doc_type=es_type)
    print("bulk_delete is running")


def run():
    loop.run_until_complete(bulk_delete())


loop = asyncio.get_event_loop()
if __name__ == '__main__':
    run()
